import SlideSelectBase from './SlideSelectBase.vue'
import BtnsBar from './BtnsBar.vue'
import VMask from '@/modules/base/VMask.vue'
export default {
  components: {
    SlideSelectBase,
    BtnsBar,
    VMask
  },
  props: {
    btns: {
      type: Array,
      default: function () {
        return [
          {
            name: '取消',
            style: 'gray',
            fn: () => {
              this.onClose()
            }
          },
          {
            name: '确定',
            fn: () => {
              this.confirm()
            }
          }
        ]
      }
    }
  },
  data () {
    return {
      isShow: 0
    }
  },
  methods: {
    confirm () {
      if (this.$refs.vSlideSelectBase.confirm()) {
        this.onClose()
      }
    },
    onClose () {
      this.$emit('close')
      this.close()
    },
    close () {
      this.isShow = 0
    },
    show (options) {
      this.isShow = 1
      this.$emit('show')
      if (options) {
        this.setOptions(options)
      }
    },
    async setOptions (options) {
      await this.$nextTick()
      this.$refs.vSlideSelectBase.setOptions(options)
    }
  }
}
